{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% extends base_template %}

{% block field %}
    {% if field_description.options.edit == 'inline' %}
        {% for nested_field_description in field_description.associationadmin.formfielddescriptions %}
            {{ nested_field_description|render_form_element(field_element, value) }}
        {% endfor %}

    {% else %}

        <div id="field_container_{{ field_element.id }}">

            {% if field_description.options.edit == 'list' %}
                <span id="field_widget_{{ field_element.id }}" >
                    {% if value.id %}
                        {% render 'SonataAdminBundle:Core:getShortObjectDescription' with {
                            'code': field_description.associationadmin.code,
                            'objectId': value.id,
                            'uniqid':  field_description.associationadmin.uniqid
                        }%}
                    {% endif %}
                </span>
                <span style="display: none" >
                    {{ form_field(field_element) }}
                </span>
            {% else %}
                <span id="field_widget_{{ field_element.id }}" >
                    {{ form_field(field_element) }}
                </span>
            {% endif %}
            <span id="field_actions_{{ field_element.id }}" >

                {% if field_description.options.edit == 'list' %}
                    <a  href="{{ field_description.associationadmin.generateUrl('list') }}"
                        onclick="start_field_dialog_form_list_{{ field_element.id }}(event)"
                        class="sonata-ba-action">
                            <img
                                src="{{ asset('bundles/sonataadmin/famfamfam/application_view_list.png') }}"
                                alt="{% trans 'btn_add' from 'AdminBundle' %}"
                            />
                          </a>
                {% endif %}

                <a  href="{{ field_description.associationadmin.generateUrl('create') }}"
                    onclick="start_field_dialog_form_add_{{ field_element.id }}(event)"
                    class="sonata-ba-action">
                        <img
                            src="{{ asset('bundles/sonataadmin/famfamfam/add.png') }}"
                            alt="{% trans 'btn_add' from 'AdminBundle' %}"
                        />
                </a>
            </span>

            <div class="container sonata-ba-modal sonata-ba-modal-edit-one-to-one" style="display: none" id="field_dialog_{{ field_element.id }}">

            </div>
        </div>

        {% include 'SonataAdminBundle:CRUD:edit_many_association_script.html.twig' %}
    {% endif %}
{% endblock %}